<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>订单系统首页</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            color: #333;
            padding: 20px;
        }

        .container {
            max-width: 1200px;
            width: 100%;
            margin: 0 auto;
            display: flex;
            flex-direction: column;
            height: 100vh;
            gap: 20px;
        }

        /* 上层样式 */
        .header {
            background-color: rgba(255, 255, 255, 0.95);
            border-radius: 15px;
            padding: 20px;
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
            display: flex;
            justify-content: space-between;
            align-items: center;
            animation: slideDown 0.6s ease-out;
        }

        .user-info {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .user-avatar {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            background: linear-gradient(45deg, #6a11cb, #2575fc);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 24px;
            font-weight: bold;
        }

        .user-details h2 {
            font-size: 24px;
            color: #2c3e50;
            margin-bottom: 5px;
        }

        .user-details p {
            color: #7f8c8d;
            font-size: 14px;
        }

        .profile-btn {
            background: linear-gradient(to right, #6a11cb, #2575fc);
            color: white;
            border: none;
            padding: 12px 30px;
            border-radius: 30px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 15px rgba(106, 17, 203, 0.4);
        }

        .profile-btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 20px rgba(106, 17, 203, 0.6);
        }

        .profile-btn:active {
            transform: translateY(1px);
        }

        /* 中层样式 */
        .main-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background-color: rgba(255, 255, 255, 0.85);
            border-radius: 15px;
            padding: 40px;
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
            animation: fadeIn 1s ease-out;
        }

        .order-btn {
            width: 200px;
            height: 200px;
            border-radius: 50%;
            background: linear-gradient(45deg, #6a11cb, #2575fc);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.4s ease;
            box-shadow: 0 10px 30px rgba(106, 17, 203, 0.5);
            position: relative;
            overflow: hidden;
            border: none;
        }

        .order-btn:hover {
            transform: scale(1.05);
            box-shadow: 0 15px 40px rgba(106, 17, 203, 0.7);
        }

        .order-btn:active {
            transform: scale(0.98);
        }

        .order-btn::after {
            content: "";
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: rgba(255, 255, 255, 0.1);
            transform: rotate(30deg);
            transition: all 0.6s;
        }

        .order-btn:hover::after {
            transform: rotate(30deg) translate(20%, 20%);
        }

        .btn-label {
            margin-top: 30px;
            font-size: 20px;
            color: #2c3e50;
            font-weight: 600;
        }
        /* 分页控件 */
        .pagination {
            display: flex;
            justify-content: center;
            padding: 30px;
            gap: 12px;
        }

        .pagination button {
            background-color: var(--primary);
            color: black;
            border: none;
            height: 40px;
            padding: 0 16px;
            border-radius: 6px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 2px 6px rgba(74, 108, 247, 0.3);
        }

        .pagination button:hover:enabled {
            background-color: #3a5ce0;
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(74, 108, 247, 0.3);
        }

        .pagination button:disabled {
            background-color: #eef2f7;
            color: #cbd5e1;
            cursor: not-allowed;
            box-shadow: none;
        }
        /* 下层样式 */
        .order-section {
            background-color: rgba(255, 255, 255, 0.95);
            border-radius: 15px;
            padding: 25px;
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
            animation: slideUp 0.8s ease-out;
        }

        .section-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 2px solid #f0f0f0;
        }

        .section-title {
            font-size: 22px;
            color: #2c3e50;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .order-list {
            min-height: 200px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: #7f8c8d;
        }

        .order-placeholder {
            text-align: center;
            padding: 40px;
        }

        .order-placeholder i {
            font-size: 48px;
            margin-bottom: 15px;
            color: #bdc3c7;
        }

        .order-placeholder p {
            font-size: 18px;
            margin-top: 10px;
        }
        /* 订单项样式 */
        .order-item {
            background-color: white;
            border-radius: 10px;
            padding: 20px;
            margin-bottom: 15px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
            cursor: pointer;
            width: 100%;
        }

        .order-item:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
        }

        .order-item > div {
            margin: 5px 0;
            display: flex;
            align-items: center;
        }

        .order-item > div i {
            margin-right: 10px;
            color: #6a11cb;
        }

        /* 订单状态颜色区分 */
        .order-status.pending {
            color: #ffa502;
        }

        .order-status.in_transit {
            color: #2575fc;
        }

        .order-status.completed {
            color: #25d366;
        }


        /* 动画 */
        @keyframes slideDown {
            from {
                transform: translateY(-50px);
                opacity: 0;
            }
            to {
                transform: translateY(0);
                opacity: 1;
            }
        }

        @keyframes slideUp {
            from {
                transform: translateY(50px);
                opacity: 0;
            }
            to {
                transform: translateY(0);
                opacity: 1;
            }
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: scale(0.8);
            }
            to {
                opacity: 1;
                transform: scale(1);
            }
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .header {
                flex-direction: column;
                text-align: center;
                gap: 20px;
            }

            .user-info {
                flex-direction: column;
            }

            .order-btn {
                width: 170px;
                height: 170px;
                font-size: 24px;
            }

            .btn-label {
                font-size: 18px;
            }
        }
    </style>
</head>
<body>
<div class="container">
    <!-- 上层：用户信息 -->
    <header class="header">
        <div class="user-info">
            <!-- 数据接口：后端需提供 User 对象 -->
            <!-- 用户头像（根据用户名首字母生成） -->
            <div class="user-avatar" th:text="${user != null ? user.username.substring(0,1).toUpperCase() : 'U'}"></div>
            <div class="user-details">
                <!-- 用户名接口 -->
                <h2 th:text="${user != null ? user.username : '未登录用户'}"></h2>
                <p>欢迎使用订单系统</p>
            </div>
        </div>
        <!-- 个人空间按钮（预留跳转接口） -->
        <button class="profile-btn" onclick="location.href='/clients/clientuserspace'">
            <i class="fas fa-user-circle"></i> 个人空间
        </button>
    </header>

    <!-- 中层：下单按钮 -->
    <main class="main-content">
        <!-- 下单按钮（预留跳转接口） -->
        <button class="order-btn" onclick="location.href='/clients/clientorder'">
            下单
        </button>
        <div class="btn-label">点击按钮创建新订单</div>
    </main>

    <!-- 下层：订单列表 -->
    <section class="order-section">
        <div class="section-header">
            <h2 class="section-title"><i class="fas fa-receipt"></i> 我的订单</h2>
        </div>
        <!-- 数据接口：后端需提供 List<Order> 类型的 orders 变量 -->
        <div class="order-list" th:if="${orders == null}">
            <div class="order-placeholder">
                <i class="fas fa-inbox"></i>
                <h3>暂无订单记录</h3>
                <p>您还没有创建任何订单</p>
            </div>
        </div>
        <!-- 当有订单数据时显示（预留订单列表接口） -->
        <div class="order-list" th:if="${orders != null}">
            <!-- 订单列表循环接口 -->
            <div th:each="order : ${orders}" class="order-item" th:onclick="'location.href=\'/clients/clientorderdetail?orderId=' + ${order.orderId} + '\''">
                <span class="order-id"><i class="fas fa-hashtag"></i><span th:text="'订单号: ' + ${order.orderId}"></span></span>
                <span class="order-date"><i class="fas fa-calendar-alt"></i><span th:text="'日期: ' + ${order.createdAt}"></span></span>
                <span class="order-status" th:classappend="${order.deliveryStatus}"><i class="fas fa-truck"></i><span th:text="'状态: ' + ${order.deliveryStatus}"></span></span>
                <span class="order-amount"><i class="fas fa-yen-sign"></i><span th:text="'金额: ' + ${order.totalAmount} + ' 元'"></span></span>
            </div>
        </div>

        <div class="pagination">
            <button th:disabled="${currentPage == 1}"
                    th:onclick="'location.href=\'/clients/clientmain?page=' + (${currentPage} - 1) + '&size=4\''">上一页</button>

            <span th:text="'第 ' + ${currentPage} + ' 页 / 共 ' + ${totalPages} + ' 页'"></span>

            <button th:disabled="${currentPage == totalPages}"
                    th:onclick="'location.href=\'/clients/clientmain?page=' + (${currentPage} + 1) + '&size=4\''">下一页</button>
        </div>
    </section>
</div>

<script>
    // 添加按钮交互效果
    document.querySelector('.order-btn').addEventListener('click', function() {
        this.classList.add('clicked');
        setTimeout(() => {
            this.classList.remove('clicked');
        }, 300);
    });

    // 模拟动态效果
    setInterval(() => {
        const btn = document.querySelector('.order-btn');
        btn.style.boxShadow = `0 15px 40px rgba(106, 17, 203, ${0.5 + Math.random() * 0.3})`;
    }, 2000);
</script>
</body>
</html>